﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Spreadsheet;
using DotNetCore.CAP;
using Microsoft.Extensions.Configuration;
using NP.BPMReportPlatform.Common;
using NP.BPMReportPlatform.DBHelper;
using NP.BPMReportPlatform.Entities.BPM_Business;
using NP.BPMReportPlatform.Entities.BPM_Platform;
using NP.BPMReportPlatform.RecurringJobs.Dto;
using NP.Enterprise.Utils.Http;
using SqlSugar;
using static NP.BPMReportPlatform.Contract.Dtos.ContractEnum;

namespace NP.BPMReportPlatform.RecurringJobs
{
    /// <summary>
    /// 臻辅材库存维护定时催办
    /// </summary>
    public class ZFCInventoryRecurringJob : BpmReportPlatformRecurringJob, IZFCInventoryRecurringJob
    {
        private readonly INPRestHttpHelper _httpClient;
        private readonly IConfiguration _configuration;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="sqlSugarAppService"></param>
        public ZFCInventoryRecurringJob(INPRestHttpHelper httpClient, IConfiguration configuration)
        {
            _httpClient = httpClient;
            _configuration = configuration;
        }

        /// <summary>
        /// 定时更新新增订单、当天未清订单到SUS
        /// </summary>
        /// <returns></returns>
        public async Task UpdateAddQty()
        {
            var webapi = _configuration["SUS:susUrl"] + "/recurringJob/UpdateAddQty";
            await _httpClient.GetAsync(webapi);
        }

        /// <summary>
        /// 通过企业微信发送消息给供应商，通知维护库存
        /// </summary>
        /// <returns></returns>
        public async Task SendWeChatMessageToSupplier()
        {
            var webapi= _configuration["SUS:susUrl"]+ "/recurringJob/sendWeChatMessageToSupplier";
            await _httpClient.GetAsync(webapi);
        }

        /// <summary>
        /// 发送邮件给产品人，抄送主管
        /// </summary>
        /// <returns></returns>
        public async Task SendEmailToSupplierOwner()
        {
            var webapi = _configuration["SUS:susUrl"] + "/recurringJob/sendEmailToSupplierOwner";
            await _httpClient.GetAsync(webapi);
        }

        /// <summary>
        /// 定时更新臻辅材供应商信息到sus
        /// </summary>
        /// <returns></returns>
        public async Task SyncSupplierListToSUS()
        {
            var webapi = _configuration["SUS:susUrl"] + "/recurringJob/SyncSupplierListToSUS";
            await _httpClient.GetAsync(webapi);
        }
        /// <summary>
        /// 定时更新历史批次号
        /// </summary>
        /// <returns></returns>
        public async Task UpdateHistoryINIQTY()
        {
            var webapi = _configuration["SUS:susUrl"] + "/recurringJob/UpdateHistoryINIQTY";
            await _httpClient.GetAsync(webapi);
        }
        /// <summary>
        /// 定时发送批次号预警邮件给管理员和产品人
        /// </summary>
        /// <returns></returns>
        public async Task SendBCOverdueEmailToSupplierOwner()
        {
            var webapi = _configuration["SUS:susUrl"] + "/recurringJob/SendZFCSupplierBCOverdueEmail";
            await _httpClient.GetAsync(webapi);
        }

    }
}